<script>
export default {
	globalData: {
		statusBarHeight: 0, // 状态栏高度
		navBarHeight: 0, // 导航栏高度
		safeAreaHeight: 0, // 底部安全区域高度
		menuRight: 0, // 胶囊右侧间隙大小
		menuTop: 0, // 胶囊顶部间隙大小
		menuBottom: 0, // 胶囊底部间隙大小
		menuHeight: 0, // 胶囊高度
		menuWidth: 0, // 胶囊宽度
	},
	onLaunch: function() {
		// 获取系统信息
		const { statusBarHeight, screenWidth, screenHeight, safeArea } = uni.getSystemInfoSync();
		
		// #ifdef MP-WEIXIN
		// 胶囊按钮位置信息
		const { top, right, height, width } = uni.getMenuButtonBoundingClientRect();
		this.globalData.navBarHeight = (top - statusBarHeight) * 3 + height + statusBarHeight;
		this.globalData.menuRight = screenWidth - right;
		this.globalData.menuTop = top;
		this.globalData.menuBottom = (top - statusBarHeight) * 2;
		this.globalData.menuHeight = height;
		this.globalData.menuWidth = width;
		// #endif
		
		this.globalData.statusBarHeight = statusBarHeight;
		this.globalData.safeAreaHeight = screenHeight - safeArea.bottom;
	},
	onShow: function() {
		console.log('App Show')
		// getApp().globalData.projectId,globalData.projectId
	
		const updateManager = uni.getUpdateManager();
	
		updateManager.onCheckForUpdate(function(res) {
			// 请求完新版本信息的回调
			console.log(res.hasUpdate, 'res.hasUpdate');
		});
	
		updateManager.onUpdateReady(function(res) {
			uni.showModal({
				title: '更新提示',
				content: '新版本已经准备好，是否重启应用？',
				success(res) {
					if (res.confirm) {
						// 新的版本已经下载好，调用 applyUpdate 应用新版本并重启
						updateManager.applyUpdate();
					}
				}
			});
	
		});
	
		updateManager.onUpdateFailed(function(res) {
			// 新的版本下载失败
		});
	},
}
</script>

<style lang="scss">
@import './wxcomponents/vant/dist/common/index.wxss';
@import "@/uni_modules/uview-ui/index.scss";

</style>
